<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>peach.nn.af.Activation</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="peach-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a href="http://code.google.com/p/peach">Peach - Computational Intelligence for Python</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="peach-module.html">Package&nbsp;peach</a> ::
        <a href="peach.nn-module.html">Package&nbsp;nn</a> ::
        <a href="peach.nn.af-module.html">Module&nbsp;af</a> ::
        Class&nbsp;Activation
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="peach.nn.af.Activation-class.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== CLASS DESCRIPTION ==================== -->
<h1 class="epydoc">Class Activation</h1><p class="nomargin-top"><span class="codelink"><a href="peach.nn.af-pysrc.html#Activation">source&nbsp;code</a></span></p>
<center>
<center>  <map id="uml_class_diagram_for_peach_nn" name="uml_class_diagram_for_peach_nn">
<area shape="rect" id="node1" href="peach.nn.af.Gaussian-class.html" title="Gaussian activation function" alt="" coords="325,193,416,231"/>
<area shape="rect" id="node82" href="peach.nn.af.Activation-class.html#d" title="An alias to the derivative of the function." alt="" coords="336,31,527,49"/>
<area shape="rect" id="node82" href="peach.nn.af.Activation-class.html#__init__" title="Initializes the activation function." alt="" coords="336,52,527,71"/>
<area shape="rect" id="node82" href="peach.nn.af.Activation-class.html#__call__" title="Call interface to the object." alt="" coords="336,71,527,89"/>
<area shape="rect" id="node82" href="peach.nn.af.Activation-class.html#derivative" title="An estimate of the derivative of the activation function." alt="" coords="336,89,527,108"/>
<area shape="rect" id="node2" href="peach.nn.af.Activation-class.html" title="Base class for activation functions." alt="" coords="324,6,537,114"/>
<area shape="rect" id="node3" href="peach.nn.af.Ramp-class.html" title="Ramp activation function" alt="" coords="5,134,77,173"/>
<area shape="rect" id="node4" href="peach.nn.af.Linear-class.html" title="Identity activation function" alt="" coords="107,134,179,173"/>
<area shape="rect" id="node5" href="peach.nn.af.Signum-class.html" title="Signum activation function" alt="" coords="208,134,288,173"/>
<area shape="rect" id="node6" href="peach.nn.af.RadialBasis-class.html" title="This class is used as a base class for radial basis functions (RBFs). It is in almost every aspect equal to Activation class, but it is used to distinguish the two types. RBFs are used in Radial Basis Function Networks, in which monotonic activations shouldn&#39;t be used." alt="" coords="317,134,424,173"/>
<area shape="rect" id="node7" href="peach.nn.af.Sigmoid-class.html" title="Sigmoid activation function" alt="" coords="453,134,536,173"/>
<area shape="rect" id="node8" href="peach.nn.af.ArcTan-class.html" title="Inverse tangent activation function" alt="" coords="565,134,643,173"/>
<area shape="rect" id="node9" href="peach.nn.af.Threshold-class.html" title="Threshold activation function." alt="" coords="672,134,765,173"/>
<area shape="rect" id="node10" href="peach.nn.af.TanH-class.html" title="Hyperbolic tangent activation function" alt="" coords="795,134,864,173"/>
</map>
  <img src="uml_class_diagram_for_peach_nn.gif" alt='' usemap="#uml_class_diagram_for_peach_nn" ismap="ismap" class="graph-without-title" />
</center>
</center>
<hr />
<p>Base class for activation functions.</p>
<p>This class can be used as base for activation functions. A subclass should
have at least three methods, described below:</p>
<blockquote>
<dl class="rst-docutils">
<dt>__init__</dt>
<dd>This method should be used to configure the function. In general, some
parameters to change the behaviour of a simple function is passed. In a
subclass, the <tt class="rst-docutils literal">__init__</tt> method should call the mother class
initialization procedure.</dd>
<dt>__call__</dt>
<dd>The <tt class="rst-docutils literal">__call__</tt> interface is the function call. It should receive a
<em>vector</em> of real numbers and return a <em>vector</em> of real numbers. Using
the capabilities of the <tt class="rst-docutils literal">numpy</tt> module will help a lot. In case you
don't know how to use, maybe instantiating this class instead will work
better (see below).</dd>
<dt>derivative</dt>
<dd>This method implements the derivative of the activation function. It is
used in the learning methods. If one is not provided (but remember to
call the superclass <tt class="rst-docutils literal">__init__</tt> so that it is created).</dd>
</dl>
</blockquote>

<!-- ==================== INSTANCE METHODS ==================== -->
<a name="section-InstanceMethods"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Instance Methods</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-InstanceMethods"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="peach.nn.af.Activation-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">f</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">df</span>=<span class="summary-sig-default">None</span>)</span><br />
      Initializes the activation function.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="peach.nn.af-pysrc.html#Activation.__init__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="peach.nn.af.Activation-class.html#__call__" class="summary-sig-name">__call__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">x</span>)</span><br />
      Call interface to the object.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="peach.nn.af-pysrc.html#Activation.__call__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="peach.nn.af.Activation-class.html#derivative" class="summary-sig-name">derivative</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">x</span>,
        <span class="summary-sig-arg">dx</span>=<span class="summary-sig-default">5e-05</span>)</span><br />
      An estimate of the derivative of the activation function.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="peach.nn.af-pysrc.html#Activation.derivative">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
      <code>__delattr__</code>,
      <code>__format__</code>,
      <code>__getattribute__</code>,
      <code>__hash__</code>,
      <code>__new__</code>,
      <code>__reduce__</code>,
      <code>__reduce_ex__</code>,
      <code>__repr__</code>,
      <code>__setattr__</code>,
      <code>__sizeof__</code>,
      <code>__str__</code>,
      <code>__subclasshook__</code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== INSTANCE VARIABLES ==================== -->
<a name="section-InstanceVariables"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Instance Variables</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-InstanceVariables"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="d"></a><span class="summary-name">d</span><br />
      An alias to the derivative of the function.
    </td>
  </tr>
</table>
<!-- ==================== PROPERTIES ==================== -->
<a name="section-Properties"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Properties</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Properties"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
      <code>__class__</code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== METHOD DETAILS ==================== -->
<a name="section-MethodDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Method Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-MethodDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="__init__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">f</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">df</span>=<span class="sig-default">None</span>)</span>
    <br /><em class="fname">(Constructor)</em>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="peach.nn.af-pysrc.html#Activation.__init__">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Initializes the activation function.</p>
<p>Instantiating this class creates and adjusts a standard Python function
to work with layers of neurons.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>f</code></strong> - The activation function. It can be created as a lambda function or
any other method, but it should take a real value, corresponding to
the activation potential of a neuron, and return a real value,
corresponding to its activation. Defaults to <tt class="rst-docutils literal">None</tt>, if none is
given, the identity function is used.</li>
        <li><strong class="pname"><code>df</code></strong> - The derivative of the above function. It can be defined as above, or
not given. If not given, an estimate is calculated based on the
given function. Defaults to <tt class="rst-docutils literal">None</tt>.</li>
    </ul></dd>
    <dt>Overrides:
        object.__init__
    </dt>
  </dl>
</td></tr></table>
</div>
<a name="__call__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__call__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">x</span>)</span>
    <br /><em class="fname">(Call operator)</em>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="peach.nn.af-pysrc.html#Activation.__call__">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Call interface to the object.</p>
<p>This method applies the activation function over a vector of activation
potentials, and returns the results.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>x</code></strong> - A real number or a vector of real numbers representing the
activation potential of a neuron or a layer of neurons.</li>
    </ul></dd>
    <dt>Returns:</dt>
        <dd>The activation function applied over the input vector.</dd>
  </dl>
</td></tr></table>
</div>
<a name="derivative"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">derivative</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">x</span>,
        <span class="sig-arg">dx</span>=<span class="sig-default">5e-05</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="peach.nn.af-pysrc.html#Activation.derivative">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>An estimate of the derivative of the activation function.</p>
<p>This method estimates the derivative using difference equations. This is
a simple estimate, but efficient nonetheless.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>x</code></strong> - A real number or vector of real numbers representing the point over
which the derivative is to be calculated.</li>
        <li><strong class="pname"><code>dx</code></strong> - The value of the interval of the estimate. The smaller this number
is, the better. However, if made too small, the precision is not
enough to avoid errors. This defaults to 5e-5, which is the values
that gives the best results.</li>
    </ul></dd>
    <dt>Returns:</dt>
        <dd>The value of the derivative over the given point.</dd>
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="peach-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a href="http://code.google.com/p/peach">Peach - Computational Intelligence for Python</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Sun Jul 31 16:59:38 2011
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
